<?php
namespace App\Services\Lib;

use Illuminate\Support\Facades\Log;

class CRSMSService extends SMSAbstract
{
    protected $url = 'http://web.cr6868.com/asmx/smsservice.aspx';

    public function sendSMS($to, $content)
    {
        // TODO: Implement sendSMS() method.
        $postData = [
            'name' => $this->id,
            'pwd' => $this->pwd,
            'content' => '【'.$this->sign.'】'.$content,
            'mobile' => $to,
            'sign' => '',
            'type' => 'pt'
        ];
        $res = curlHttp($this->url, $postData, 'post');
        if ($res['http_code'] == 200) {
            $resArr = explode(',', $content);
            if ($resArr[0] == 0) {
                return true;
            }
        }
        Log::useFiles(storage_path().'/logs/sms/'.date('YmdHis').'.log');
        Log::info("【cr】短信接口出错! \t [http_code]" . $res['http_code'] . "\t[body]:".$res['body']);
        return false;
    }
}
